package com.copm.demonstrationsystem.controller.introductionfeatures;

import com.copm.demonstrationsystem.commons.response.ResponseStatus;
import com.copm.demonstrationsystem.commons.util.ControllerUtils;
import com.copm.demonstrationsystem.service.introductionfeatures.MainPageService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;


/**
 * @Author: Yuan Baiyu
 * @Date: Created in 14:57 2018/4/24
 */
@RestController
@RequestMapping("/mainpage")
@CrossOrigin
public class MainPageController {

    @Autowired
    MainPageService mainPageService;

    //获取“首页”页面信息（全为图片）
    @GetMapping
    @ApiOperation("主页的信息获取接口")
    ResponseStatus getPage() {
        return ControllerUtils.fillResponse(new ResponseStatus(),
                mainPageService.getPage());
    }


    //修改“首页”页面背景图片
    @ApiOperation("背景图片修改接口")
    @ApiImplicitParam(name = "file", value = "新的背景图片"
            , dataType = "file", paramType = "form", required = true)
    @PostMapping("/background")
    ResponseStatus modifyBackgroundImage(@RequestPart("file") MultipartFile file) {
        return ControllerUtils.fillResponse(new ResponseStatus(),
                mainPageService.modifyBackgroundImage(file));
    }

    //修改“首页”页面项目图片
    @ApiOperation("项目图片修改接口")
    @ApiImplicitParam(name = "file", value = "新的项目图片"
            , dataType = "file", paramType = "form", required = true)
    @PostMapping("/project")
    ResponseStatus modifyProjectImage(@RequestPart("file") MultipartFile file) {
        return ControllerUtils.fillResponse(new ResponseStatus(),
                mainPageService.modifyProjectImage(file));
    }


    //-----------------------------------------------------------------------------------------------------------------
//
//    //添加“首页”页面模块标签文本
//    @ApiOperation("标签文本添加接口")
//    @ApiImplicitParam(name = "title", value = "新的标签文本内容"
//            , dataType = "String", paramType = "query", required = true)
//    @PostMapping("/text")
//    ResponseStatus addText(@RequestParam(("title")) String title) {
//        return ControllerUtils.fillResponse(new ResponseStatus(),
//                mainPageService.addMainPageText(title));
//    }
//
//    //删除“首页”页面模块标签文本
//    @ApiOperation("标签文本删除接口")
//    @ApiImplicitParam(name = "id", value = "待删除的标签文本标识ID"
//            , dataType = "Long", paramType = "path", required = true)
//    @DeleteMapping("/text/{id}")
//    ResponseStatus deleteText(@PathVariable("id") Long id) {
//        return ControllerUtils.fillResponse(new ResponseStatus(),
//                mainPageService.deleteMainPageText(id));
//    }
//
//    //修改“首页”页面模块标签文本
//    @ApiOperation("标签文本修改接口")
//    @ApiImplicitParams({@ApiImplicitParam(name = "title", value = "新的标签文本内容"
//            , dataType = "String", paramType = "query", required = true),
//            @ApiImplicitParam(name = "id", value = "待修改的标签文本标识ID"
//                    , dataType = "Long", paramType = "path", required = true)})
//    @PutMapping("/text/{id}")
//    ResponseStatus modifyText(@PathVariable("id") Long id, @RequestParam("title") String title) {
//        return ControllerUtils.fillResponse(new ResponseStatus(),
//                mainPageService.modifyMainPageText(id, title));
//    }


    //-----------------------------------------------------------------------------------------------------------------
//添加“首页”页面背景图片
//    @ApiOperation("背景图片添加接口")
//    @ApiImplicitParam(name = "file", value = "新的背景图片"
//            , dataType = "file", paramType = "form", required = true)
//    @PostMapping("/background")
//    ResponseStatus addBackgroundImage(@RequestPart("file") MultipartFile file) {
//        return ControllerUtils.fillResponse(new ResponseStatus(),
//                mainPageService.addBackgroundImage(file));
//    }
//
//    //添加“首页”页面项目图片
//    @ApiOperation("项目图片添加接口")
//    @ApiImplicitParam(name = "file", value = "新的项目图片"
//            , dataType = "file", paramType = "form", required = true)
//    @PostMapping("/project")
//    ResponseStatus addProjectImage(@RequestPart("file") MultipartFile file) {
//        return ControllerUtils.fillResponse(new ResponseStatus(),
//                mainPageService.addProjectImage(file));
//    }
//
//    //删除“首页”页面背景图片
//    @ApiOperation("背景图片删除接口")
//    @DeleteMapping("/background")
//    ResponseStatus deleteBackgroundImage() {
//        return ControllerUtils.fillResponse(new ResponseStatus(),
//                mainPageService.deleteBackgroundImage());
//    }
//
//    //删除“首页”页面项目图片
//    @ApiOperation("项目图片删除接口")
//    @DeleteMapping("/project")
//    ResponseStatus deleteProjectImage() {
//        return ControllerUtils.fillResponse(new ResponseStatus(),
//                mainPageService.deleteProjectImage());
//    }
}
